<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%@ include file="function.jsp"%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>医院列表</title>
    <%-- <link  href="../../hos_manage/images/favicon.ico" rel="shortcut icon" type="image/x-icon"> --%>
    <link rel="stylesheet" href="/css/messages_doctor_mes.css">
    <link rel="stylesheet" href="/css/sweetalert.css" >
    <link rel="stylesheet" href="/css/pageCode.css" />
    <link rel="stylesheet" href="/css/project/project.css">
    <link rel="stylesheet" type="text/css" href="/css/project/main.css"/>
    <link rel="stylesheet" href="/css/project/user.css">
    <link rel="stylesheet" href="/css/public.css">
    <link rel="stylesheet" href="/css/basic/basic.css">
    <!--[if lte IE 9]>
        <link rel="stylesheet" href="/css/ie_basic.css">
    <![endif]-->

    <script src="../js/jquery-1.9.1.min.js"></script>
</head>
<body>
    <%@ include file="../header.jsp"%>
    <!--内容-->
    <div class="containerone">
    <%@ include file="../left_menu.jsp"%>
        <!--右边内容-->
        <div class="right_cont">
        <!--右边导航下面内容-->
            <div class="message_hos_news_container" id="show_project_main">
                <div id="topbar-right" class="flex">
                    <div id="userList">
                        <div class="memberList_header">
                            <div>天下布医医院列表</div>
                        </div>
                        <div class="js_title title box js_title_group">
                            <span class="js_title_party box flex ">
                                <p class="name flex" style="width:20%">医院编号</p>
                                <p class="start-time flex" style="width:30%">医院名称</p>
                                <p class="end-time flex" style="width:40%">医院描述</p>
                                <p class="flex" style="width:10%">操作</p>
                            </span>
                        </div>
                        <div class="js_title title box user-title" v-for="data in datas">
                            <span class="js_title_party box flex flex-middle"
                                <%if (checkAuth("医院详情", input)) {%>@click="detail(data)"<%}%>>
                                <p class="name flex flex-middle" style="width:20%" v-html="data.hospital_id"></p>
                                <p class="start-time flex flex-middle" style="width:30%" v-html="data.name"></p>
                                <p class="end-time flex flex-middle" style="width:40%" v-html="data.descr"></p>
                                <p style="width:10%">
                                    <%
                                        if (checkAuth("编辑医院信息", input)) {
                                    %>
                                    <span class="href" @click="edit(data)">编辑</span>
                                    <%
                                        }
                                    %>

                                </p>
                            </span>
                        </div>
                        <pagination :pagecount="page_count" :currentpage="current_page"></pagination>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/js/sweetalert-dev.js"></script>
    <%@ include file="/components/pagination.jsp"%>
    <script type="text/javascript">
        new Vue({
            el: "#show_project_main",
            data: function() {
    			return {
    				datas: [],
                    hospital: {},
                    hospitalList: [],
                    page_count: 0,
                    current_page: 1,
                    count: 0,
    			}
    		},
            computed: {
                pageDValue: function() {
                    var x = this.current_page;
                    if (x < 6 / 2 + 1 || this.page_count <= 6) {
                        return 1;
                    }
                    if (x > this.page_count - 6 / 2) {
                        return this.page_count - 6 + 1;
                    }
                    return x - 6 / 2;
                },
                showPageNum: function() {
                    if (this.page_count < 6) {
                        return this.page_count;
                    } else {
                        return 6;
                    }
                },
            },
            methods: {
                edit: function(data) {
                    saveParmsHerf("hospitals", {
                        current_page: this.current_page
                    });
                    locationHerf("edit_hospital", {
                        data: data,
                    });
                    event.stopPropagation();
                },
                changePage: function(i) {
                    if (i > this.page_count || i <= 0) {
                        return;
                    }
                    this.current_page = i;
                    this.getProject();
                },
                dalay: function(func) {
                    var self = this;
                    if (this.timeout) {
                        clearTimeout(this.timeout);
                    }
                    this.timeout = setTimeout(function() {
                        self[func]();
                    }, 700);
                },
    			detail: function(data) {
                    saveParmsHerf("hospitals", {
                        current_page: this.current_page
                    });
                    locationHerf("see_hospital", {
                        data: data,
                        current_page: this.current_page,
                    });
    			},
                getProject: function() {
                    var self = this;
                    $.ajax({
        				data: {
        					page: this.current_page + "",
                            type: -1,
        					act: "hospital_by_page",
        				},
        				url: "hospitals.jsp",
        				success: function(res) {
        					res = JSON.parse(res);
        					if (res.errcode == 0) {
        						self.datas = res.data.rank;
                                self.count = res.data.count;
                                self.page_count = res.data.page_count;
                                self.current_page = res.data.current_page;
        					}
        				}
        			});
                }
    		},
    		ready: function() {
                var self = this;
                var parms = getHrefParms("hospitals");
                if (parms) {
                    clearHrefParms("hospitals");
                    this.current_page = parms.current_page;
                }
                self.getProject();
    		},
            // 需要重写的方法
            events: {
                changePage: function(i) {
                    this.current_page = i.currentpage;
                    this.getProject();
                },
            },
            components: {
                pagination: pagination,
            }
        });
    </script>
</body>
</html>
